import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { MyDayComponent } from './myDay/my-day.component';
import { TodoComponent } from './todo/todo.component';
import { SearchComponent} from './search/search.component';
import { HomeComponent } from './home/home.component';
import { LoginComponent } from './login/login.component';
import { AuthGuard } from './_common/_guards/auth.guard';

const routes: Routes = [
  {
    path: 'login',
    component: LoginComponent
  },
  {
    path: '',
    component: HomeComponent,
    canActivate: [AuthGuard], // 路由守卫
    children: [
      {
        path: 'my-day',
        component: MyDayComponent
      },
      {
        path: 'lists/:id',
        component: TodoComponent
      },
      {
        path: 'search',
        component: SearchComponent
      }
    ]
  }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})

export class AppRoutingModule { }
